package com.wxk.lambda.syntax;

import com.wxk.lambda.data.Person;

/**
 * wxk
 */
public class Syntax4 {

    public static void main(String[] args) {

        PersonCreator creator = () -> new Person();

        //构造方法的引用:无参构造函数
        PersonCreator creator1 = Person::new;
        Person a = creator1.getPerson();
        System.out.println("a:" + a.toString());

        //构造方法的引用:有参构造函数
        PersonCreator2 creator2 = Person::new;
        Person b = creator2.getPerson("zhangsan", 18);
        System.out.println("b:" + b.toString());


    }
}


//需求
interface PersonCreator {

    Person getPerson();
}

interface PersonCreator2 {
    Person getPerson(String name, int age);
}